#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;

int main() {

    class Date
    {
    public:
        Date(int year = 1900, int month = 1, int day = 1)
        {
            _year = year;
            _month = month;
            _day = day;
        }
        static int GetMonthDay(int year, int Month)
        {
            int MonthDay[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
            if (Month == 2 &&
                ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0))
            {
                return 29;
            }
            return MonthDay[Month];
        }
        int YearDay()
        {
            if (_month == 1)
            {
                return _day;
            }
            else
            {
                while (_num < _month)
                {
                    _sum += GetMonthDay(_year, _num);
                    ++_num;
                }
                _sum += _day;
                return _sum;
            }
        }
    private:
        int _year;
        int _month;
        int _day;
        int _num = 1;
        int _sum = 0;
    };
    int year = 1;
    int day = 1;
    int month = 1;
    scanf("%d %d %d", &year, &month, &day);
    Date d1(year, month, day);
    int sum = d1.YearDay();
    cout << sum << endl;
}